<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags"  prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>股价分析</title>
    <link rel="stylesheet" type="text/css"	href="./styles/finance.css">
    <script type="text/javascript" src="./javaScripts/calendar.js"></script>
    <SCRIPT type="text/javascript">
    	function clearValue(id){
	    	id.value="";
    	}
    	function fillName(id,name){
    		if(null==id.value || ""==id.value){
    			id.value=name;
    		};
    	}
    	function IsDate(str)
		//_________是否为日期（YYYY-MM-DD）类型字符串_________________________
		{
		    var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
		    if (r == null) return false;
		    var d = new Date(r[1], r[3]-1, r[4]);
		    return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
		}
		function   isInt(s) 
		{ //匹配整数
			var   patrn=/^[1-9]d*|0$/; 
			if   (!patrn.exec(s)) {  
				return   false; 
			}
			return   true; 
		} 
		function   isFloat(s) 
		{ //匹配浮点数
			var   patrn=/^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$/; 
			if   (!patrn.exec(s)) {  
				return   false; 
			}
			return   true; 
		} 
    	function validate(id){
    		var startDate=$("#startDate").val();
    		var endDate=jQuery("#endDate").val();
    		if(!IsDate($("#startDate").val())){
    			alert("请输入正确的开始时间,如：2000-1-1");
    			return false;
    		}
    		if(!IsDate(endDate)){
    			alert("请输入正确的结束时间,如：2000-1-1");
    			return false;
    		}
    		var rate=jQuery("#rate").val();
    		if(!isInt(rate) && !isFloat(rate)){
    			alert("请输入正确的股价百分比,如：百分之20.2%,则输入20.2");
    			return false;
    		}
    		var syl=jQuery("#syl").val();
    		if(!isInt(syl) && !isFloat(syl)){
    			alert("请输入正确的市盈率值,如：20.2,则输入20.2");
    			return false;
    		}
    	}
    </SCRIPT>

  </head>
  
  <body >
   		<div id="navigation">
   			当前位置: &nbsp; &nbsp;<a href="#">首页</a>&nbsp;&gt;&gt;&nbsp;<a href="<%=basePath %>price/prepareStockPrice">股价分析</a>
   					&nbsp; &gt;&gt;&nbsp;<a href="<%=basePath %>price/advSearch.jsp">股价高级分析工具</a>&nbsp;
   		</div>
   		<div id="mainContent">
			<table>
			<tr style="height:400px;" >
				<td id="leftbox" valign="top">
					<ul id="leftUl">       
						<li><a href="<%=basePath%>price/prepareStockPrice">股价小工具</a></li>
						<li><a href="<%=basePath %>price/prepareTopPrice?assistDto.updown=1">高价排行榜</a></li>
						<li><a href="<%=basePath %>price/prepareTopPrice?assistDto.updown=0">低价排行榜</a></li>
						<li><a href="<%=basePath %>price/advSearch.jsp">股价高级分析工具</a></li>
					</ul>
				</td>
				<td id="rightbox" align="center" valign="top">
				<div id="searchBox">
					<form action="price/advSearch" method="post" id="advSearch">
						<table align="center">
							<tr>
								<td>
									<select name="stockType">
										<option value="全部" selected="selected">所属板块</option>
										<s:if test="#attr.stockType == '上海'">		<option value="上海" selected="selected">上海</option></s:if>
										<s:else>	<option value="上海">上海</option></s:else>
										<s:if test="#attr.stockType == '深圳'">		<option value="深圳" selected="selected">深圳</option></s:if>
										<s:else>	<option value="深圳">深圳</option></s:else>		
										<s:if test="#attr.stockType == '创业板'">	<option value="创业板" selected="selected">创业板</option></s:if>
										<s:else>		<option value="创业板">创业板</option> </s:else>
									</select>
									<s:if test="#attr.pageStartDate ==null">
										<input type="text" id="startDate" name="pageStartDate" value ="开始时间" size="10" maxlength="10" onclick="calendar.show(this);" onfocus="clearValue(this);" title="开始时间,格式为:年-月-日,比如：20000-1-1"/>
									</s:if>
									<s:else>
										<input type="text" id="startDate" name="pageStartDate" value ="${pageStartDate }" size="10" maxlength="10" onclick="calendar.show(this);"  title="开始时间,格式为:年-月-日,比如：20000-1-1"/>
									</s:else>
									到
									<s:if test="#attr.pageEndDate ==null">
										<input type="text" id="endDate" name="pageEndDate" value ="结束时间" size="10" maxlength="10" onclick="calendar.show(this);" onfocus="clearValue(this);" title="结束时间,格式为:年-月-日,比如：20000-1-1"/>
									</s:if>
									<s:else>
										<input type="text" id="endDate" name="pageEndDate" value ="${pageEndDate }" size="10" maxlength="10" onclick="calendar.show(this);"  title="结束时间,格式为:年-月-日,比如：20000-1-1"/>
									</s:else>
									<select name="assistDto.updown">
										<s:if test="#attr.assistDto.updown le 0">
											<option value="1">股价上涨</option>
											<option value="0" selected="selected">股价下降</option>
										</s:if>
										<s:else>
											<option value="1" selected="selected">股价上涨</option>
											<option value="0">股价下降</option>
										</s:else>
									</select>
									<s:if test="#attr.pageRate ==null">
										<input type="text" name="pageRate" id="rate"  title="上升下降百分比,如：上升20%,输入20" size="5" maxlength="5" value="百分比" onfocus="clearValue(this);" onmouseout="fillName(this,'百分比');"/>
									</s:if>
									<s:else>
										<input type="text" name="pageRate"  id="rate" title="上升下降百分比,如：上升20%,输入20" size="5" maxlength="5" value="${pageRate}"/>
									</s:else>
								  <select name="sylType" id="sylType">   
						        		<option value="0" selected="selected">选择市盈率类型 </option>
						        		<s:if test="#attr.sylType == 1">
							        		<option value="1" selected="selected">  一年平均市盈率        </option>
						        		</s:if>
						        		<s:else>
							        		<option value="1">  一年平均市盈率        </option>
						        		</s:else>
						        		<s:if test="#attr.sylType == 2">
							                <option value="2"  selected="selected">  两年平均市盈率        </option>
						        		</s:if>
						        		<s:else>
							                <option value="2" >  两年平均市盈率        </option>
						        		</s:else>
						        		<s:if test="#attr.sylType == 3">
							                <option value="3"  selected="selected">  三年平均市盈率    </option>
						        		</s:if>
						        		<s:else>
							                <option value="3">  三年平均市盈率    </option>
						        		</s:else>
						   	      </select>
						          <select name="sylUpdown" id="sylUpdown">
						        		<option value="1"  selected="selected">  大于        </option>
						                <option value="0"> 小于      </option>
						          </select>
						          <s:if test="#attr.syl == null">
						        	<input type="text" name="syl" id="syl" title="市盈率值" size="5" maxlength="5" value="市盈率值" onfocus="clearValue(this);" onmouseout="fillName(this,'市盈率值');"/>
						          </s:if>
						          <s:else>
						        	<input type="text" name="syl" id="syl" title="市盈率值" size="5" maxlength="5" value="${syl}" />
						          </s:else>
									<input type="reset" value="重置"/>
									<input type="submit" value="查询" onclick="return validate(this);"/>
								</td>
							</tr>
						</table>
					</form>
				</div>
					<div id="resultList"  style="align:center;">
					 <s:if test="#attr.assistDto.totalPages gt 0">
					 	<ul>
							<li style="border-bottom:1px solid 	#CCCCCC;">
								<table>
									<tr>
									<td style="width:100px">所属板块</td>
									<td style="width:100px">开始时间	</td>
									<td style="width:100px">结束时间	</td>
									<td style="width:100px">股票代码	</td>
									<td style="width:120px">股票名称	</td>
									<td style="width:130px">
										<s:if test="#attr.pagePriceSort == 1">
											<a href="<%=basePath %>price/sortByPriceFloat.action?pagePriceSort=0"> 股价波动<font color="red" size="5px">↓</font></a>
										</s:if>
										<s:elseif test="#attr.pagePriceSort == 0">
											<a href="<%=basePath %>price/sortByPriceFloat.action?pagePriceSort=1"> 股价波动<font color="green" size="5px">↑</font></a>
										</s:elseif>
										<s:else>
											<a href="<%=basePath %>price/sortByPriceFloat.action?pagePriceSort=1"> 股价波动</a>
										</s:else>
									</td>
									<td style="width:130px">
										<s:if test="#attr.pageSylSort==1">
											<a href="<%=basePath %>price/sortBySyl.action?pageSylSort=0"> 市盈率<font color="red" size="5px">↓</font></a>
										</s:if>
										<s:elseif test="#attr.pageSylSort==0">
											<a href="<%=basePath %>price/sortBySyl.action?pageSylSort=1"> 市盈率<font color="green" size="5px">↑</font></a>
										</s:elseif>
										<s:else>
											<a href="<%=basePath %>price/sortBySyl.action?pageSylSort=1"> 市盈率</a>
										</s:else>
									</td>
									</tr>
								</table>
								</li>
								<s:iterator value="#attr.pageStockList" status="status" step="1">
									<li>
									<table>
										<tr>
								<!--  		<li>	<s:property value="id"/>		</li> -->
										<td style="width:100px">	<s:property value="stockType"/>		</td> 
										<td style="width:100px">	 <s:property value="pageStartDate"/></td>
										<td style="width:100px">	 <s:property value="pageEndDate"/>	</td>
										<td style="width:100px">	 <s:property value="stockCode"/>		</td>
										<td style="width:120px">	 <s:property value="stockName"/> 	</td>
										<td style="width:130px">
											<s:if test="assislito.updown==1"><font color="green" size="5px">↑</font> </s:if>
							  			    <s:if test="assistDto.updown==0"> <font color="red" size="5px">↓</font> </s:if>		
											<s:set name="gujia" var="gujia" scope="request" value="pagePriceFloatMap.get(#attr.id)"></s:set>
											 <s:property value="#attr.gujia"/>%
										 </td>
										<td style="width:130px">
										  <s:if test="sylUpdown==1"><font color="green" size="5px">↑</font> </s:if>
							  			  <s:if test="sylUpdown==0"> <font color="red" size="5px">↓</font> </s:if>	
											<s:set name="syl" var="syl" scope="request" value="pageSylMap.get(#attr.id)"></s:set>
											<s:property value="#attr.syl"/>	
										</td>
										</tr>
									</table>
									</li>
								</s:iterator>
							</ul>
					</s:if>
					<div  class="pageNav">
						<!--define the url of the previous page and next page-->
					     <s:url id="url_index" value="/price/advSearchPages">
					         <s:param name="assistDto.currentPages" value="1"></s:param>
					     </s:url>
					     <s:url id="url_pre" value="/price/advSearchPages">
					         <s:param name="assistDto.currentPages" value="#attr.assistDto.currentPages-1"></s:param>
					     </s:url>
					     <s:url id="url_next" value="/price/advSearchPages">
					         <s:param name="assistDto.currentPages" value="#attr.assistDto.currentPages+1"></s:param>
					     </s:url> 
					     <s:url id="url_end" value="/price/advSearchPages">
					         <s:param name="assistDto.currentPages" value="#attr.assistDto.totalPages"></s:param>
					     </s:url> 
					     <s:if test="#attr.assistDto.totalPages gt 0">
							<table align="center">
								<tr>
									<td>
										<s:if test="#attr.assistDto.currentPages <= 1">首页&nbsp;&nbsp;</s:if>
									 	<s:else><s:a href="%{url_index}">首页&nbsp;&nbsp;</s:a></s:else>
									</td>
									<td>
										<s:if test="#attr.assistDto.currentPages gt 1">
											<s:a href="%{url_pre}">上一页&nbsp;&nbsp;</s:a>
										</s:if>
										<s:else>上一页&nbsp;&nbsp;</s:else>
									</td>
									<td>第${attr.assistDto.currentPages} 页&nbsp;&nbsp;</td>
									<td>
										<s:if test="#attr.assistDto.currentPages < #attr.assistDto.totalPages">
											<s:a href="%{url_next}">下一页&nbsp;&nbsp;</s:a>
										</s:if>
										<s:else>下一页&nbsp;&nbsp;</s:else>
									</td>
									<td>
										<s:if test="#attr.assistDto.currentPages == #attr.assistDto.totalPages || #attr.assistDto.totalPages<=1">尾页&nbsp;&nbsp;</s:if>
										<s:else>
											<s:a href="%{url_end}">尾页&nbsp;&nbsp;</s:a> 
										</s:else>
									</td>
									<td>
										   共${attr.assistDto.totalPages}页 &nbsp;&nbsp;
									</td> 
								</tr>
							</table>
					     </s:if>
					</div>	
				</div>
			</td>
		</tr>
		</table>
	</div>
  </body>
</html>
